{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Untitled",
      "version": "0.3.2",
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "27OPLjn73LVf",
        "colab_type": "text"
      },
      "source": [
        "\n",
        "# Iris Species Classification\n",
        "***Classify the Iris species using Logistic Regression***\n",
        "\n",
        "![iris Virginica](https://upload.wikimedia.org/wikipedia/commons/3/38/Iris_virginica_-_NRCS.jpg)\n",
        "\n",
        "This is a simple logistic regression program to classify an iris species as either ( virginica, setosa, or versicolor) based off of the pedal length, pedal height, sepal length, and sepal height using a machine learning algorithm called Logistic Regression.\n",
        "\n",
        "\n",
        "\n",
        "**Resources:**\n",
        "\n",
        " (1) https://towardsdatascience.com/building-a-logistic-regression-in-python-301d27367c24\n",
        " \n",
        " (2) https://towardsdatascience.com/logistic-regression-a-simplified-approach-using-python-c4bc81a87c31\n",
        " \n",
        " (3) https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "wv9Yp1dSs9Zn",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "\"\"\"\n",
        "This Is A Simple Logistic Regression Program To Classify Iris Species\n",
        "\n",
        "Resources:\n",
        " (1) https://towardsdatascience.com/building-a-logistic-regression-in-python-301d27367c24\n",
        " (2) https://towardsdatascience.com/logistic-regression-a-simplified-approach-using-python-c4bc81a87c31\n",
        " (3) https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html\n",
        "\"\"\"\n",
        "\n",
        "\n",
        "# Import the dependencies\n",
        "import matplotlib.pyplot as plt\n",
        "import seaborn as sns\n",
        "from sklearn.linear_model import LogisticRegression\n",
        "from sklearn.metrics import classification_report\n",
        "from sklearn.metrics import accuracy_score\n",
        "from sklearn.model_selection import train_test_split"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QykzHudMt480",
        "colab_type": "code",
        "outputId": "179af60b-22a8-457e-db34-62fa8795f350",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 207
        }
      },
      "source": [
        "#Load the data set\n",
        "data = sns.load_dataset(\"iris\")\n",
        "data.head()"
      ],
      "execution_count": 26,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>sepal_length</th>\n",
              "      <th>sepal_width</th>\n",
              "      <th>petal_length</th>\n",
              "      <th>petal_width</th>\n",
              "      <th>species</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>5.1</td>\n",
              "      <td>3.5</td>\n",
              "      <td>1.4</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>4.9</td>\n",
              "      <td>3.0</td>\n",
              "      <td>1.4</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>4.7</td>\n",
              "      <td>3.2</td>\n",
              "      <td>1.3</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>4.6</td>\n",
              "      <td>3.1</td>\n",
              "      <td>1.5</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>5.0</td>\n",
              "      <td>3.6</td>\n",
              "      <td>1.4</td>\n",
              "      <td>0.2</td>\n",
              "      <td>setosa</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "   sepal_length  sepal_width  petal_length  petal_width species\n",
              "0           5.1          3.5           1.4          0.2  setosa\n",
              "1           4.9          3.0           1.4          0.2  setosa\n",
              "2           4.7          3.2           1.3          0.2  setosa\n",
              "3           4.6          3.1           1.5          0.2  setosa\n",
              "4           5.0          3.6           1.4          0.2  setosa"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 26
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "SkmpiAj_uE4w",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "#Prepare the training set\n",
        "\n",
        "# X = feature values, all the columns except the last column\n",
        "X = data.iloc[:, :-1]\n",
        "\n",
        "# y = target values, last column of the data frame\n",
        "y = data.iloc[:, -1]\n"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DkNWmIQNumf1",
        "colab_type": "code",
        "outputId": "548670c1-b325-4a64-c625-4bec2039723c",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 283
        }
      },
      "source": [
        "# Plot the relation of each feature with each species\n",
        "\n",
        "plt.xlabel('Features')\n",
        "plt.ylabel('Species')\n",
        "\n",
        "pltX = data.loc[:, 'sepal_length']\n",
        "pltY = data.loc[:,'species']\n",
        "plt.scatter(pltX, pltY, color='blue', label='sepal_length')\n",
        "\n",
        "pltX = data.loc[:, 'sepal_width']\n",
        "pltY = data.loc[:,'species']\n",
        "plt.scatter(pltX, pltY, color='green', label='sepal_width')\n",
        "\n",
        "pltX = data.loc[:, 'petal_length']\n",
        "pltY = data.loc[:,'species']\n",
        "plt.scatter(pltX, pltY, color='red', label='petal_length')\n",
        "\n",
        "pltX = data.loc[:, 'petal_width']\n",
        "pltY = data.loc[:,'species']\n",
        "plt.scatter(pltX, pltY, color='black', label='petal_width')\n",
        "\n",
        "plt.legend(loc=4, prop={'size':8})\n",
        "plt.show()"
      ],
      "execution_count": 28,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAAEKCAYAAABZr/GWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xt4VfWd7/H3NzsR2UoJUryAZiet\nHacRqJZ4GfASjXIsFavV0jphZpiiaZOeTtt5tF7wcdTTtHrK6ZRTRU3B6tSMtVo8o9aOFzStqK0F\nwUarnUMliYBHqJRbopTE7/ljrYS9w97J3puEvSSf1/PsJ6y1fmut37qQT9Zav/1b5u6IiIhERVGh\nKyAiIpJMwSQiIpGiYBIRkUhRMImISKQomEREJFIUTCIiEikKJhERiRQFk4iIRIqCSUREIqW40BX4\nIPrwhz/s5eXlha6GiMgHyqpVq/7k7hMGK6dgykN5eTkrV64sdDVERD5QzKw9m3K6lSciIpGiYBIR\nkUhRMImISKQomEREJFIUTCIiEikKJhERiRQFk4iIRIqCSUREIqXgwWRmE83swTzmW2JmlYOU+bKZ\n/X3+tZOBNDc3U15eTlFREeXl5ZxzzjkUFxdjZhQXF3POOeekTG9oaEgZNrP8P0U5lh/db/gjht1o\nFN9UzLibx2E32oCf4puKU34O9IndGMs4bdL/mpSyrIafN6Tu09Zmyr9fTtGNRZR/v5zm1uaU6Q0/\nbxhw/iE+wFBeDkVFwc/m5sxlGxqguBjMoLiYneMm4WZ9n/fi44JpmT6xWMr8HH985uF+nx6Lpayr\nu9/wn21cyvDG2CS6rTgsW8wf48enDG+Mpdb9ufg5fav+W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tLdx222185zvfAWDLli0sW7aMRYsWccsttwBw991388tf/pI5c+Zw\n//33Z7Wum2++mWuuuYZnnnmGMWPG8MILLwBw4okn8tRTT9HR0cHWrVtZuHAhixYtYtmyZWzatAmA\nuro6rrzySprDDTzooIN45JFHmDVrFsuXL89towegKyYRkTwtWABdXanjurqC8blcNdXX1/Otb32L\nJUuWMHXqVFpaWqiurgbgqKOOAmDKlCkUFxdzwgknsHbtWnp6erjyyitpbW1l+/btXHTRRVmt67XX\nXuPqq6/GzNi5cycnn3wyAJMnTwZg4sSJbNu2jXXr1jF16lRisVjftP56x0+aNImtW7dmv8GDUDCJ\niOSpoyO38ZmMGzeOxYsXs3HjRubPn8/MmTP5wQ9+AARf8t2wYQOvvPIKPT09vPzyy3z0ox9lzZo1\ndHZ28qtf/Yof/vCHbNiwIat1HXfcccydO5dp06YB0N3dTWtra0orOnenoqKC1tZWqqqqePXVVwEo\nKSlh165dfeX6zzNUFEwiInkqKwtu36Ubn4s777yTZcuWsXPnTq666irWrl1LdXU1Zsall17KzJkz\nOfzww7nwwgvZvHkzzc3NHHHEEaxdu5bzzjuPY445hkmTJmW1rmuvvZa6ujq2bdtGUVERS5YsSVvu\niiuuoLa2lsMPP5xx48ZRUlLCqaeeyrx583jllVe4+OKLc9vIHNhQptxIUVVV5StXrix0NURkmL32\n2mt8/OMfzzi99xlT8u28eByamnJvADGQtrY2rrvuOu69996hW+gguru7KS4upqenhxkzZrBixQqK\ni3O7lum//8xslbtXDTafrphERPLUGz772ipvqC1atIiHHnqob/iiiy7ia1/7Wk7LeOONN7jsssvo\n7Oxk/vz5OYfSvtAVUx50xSQyMgx2xSQDy/eKSc3FRUQkUhRMIiISKQomERGJFAWTiMgBJFMnrpms\nWbOGpUuXpoxra2tj3rx5AH1dIsHQdASbDQWTiMgIdsIJJzB//vyM05ODaX9RMImI7IPm1mbKv19O\n0Y1FlH+/nObWHDvKI+jE9ZRTTuGss85i6dKl3HTTTVRXV3P22WfT1tZGW1sbM2bM4I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5\n4O7w5W+R6zxXDnwKJpFoMeCr7v54ysjgdtwEYJq77w57EE/3KutuUm/R9y/TGf4sAramCUbc/cvh\nFdSngVVmNs3d38lnY0TyoWdMItHyOFAfvvIDM/ursCPPsQTvWtptZmcBibD8DmBM0vztQKWZjQpv\nw9WkW0n4bqt1Zva5cD1mZp8I//1Rd/+Nu19P8BK9Y9ItQ2S46IpJJFqWAOXAS+HrBDYDFwLNwCNm\n1gqsJHzVhru/Y2bPmdkrwC/c/crwFtwrwDqCXp8zqQVuN7PrCF4R/xPgZeC7ZvYxgqu35eE4kf1G\nzcVFRCRSdCtPREQiRcEkIiKRomASEZFIUTCJiEikKJhERCRSFEwiIhIpCiYREYkUBZOIiETK/wfI\nYQxYjIKT7AAAAABJRU5ErkJggg==\n",
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JpxxN8UKwBOh",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "#Split the data into 80% training and 20% testing\n",
        "x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "yI7TRVRAwaPU",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "#Train the model\n",
        "model = LogisticRegression()\n",
        "model.fit(x_train, y_train) #Training the model"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qDKGcVVSwmul",
        "colab_type": "code",
        "outputId": "b6fe702d-71a7-4a17-b282-28d6f328acdd",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 316
        }
      },
      "source": [
        "#Test the model\n",
        "predictions = model.predict(x_test)\n",
        "print(predictions)# printing predictions\n",
        "\n",
        "print()# Printing new line\n",
        "\n",
        "#Check precision, recall, f1-score\n",
        "print( classification_report(y_test, predictions) )\n",
        "\n",
        "print( accuracy_score(y_test, predictions))"
      ],
      "execution_count": 32,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "['versicolor' 'setosa' 'virginica' 'versicolor' 'versicolor' 'setosa'\n",
            " 'versicolor' 'virginica' 'versicolor' 'versicolor' 'virginica' 'setosa'\n",
            " 'setosa' 'setosa' 'setosa' 'versicolor' 'virginica' 'versicolor'\n",
            " 'versicolor' 'virginica' 'setosa' 'virginica' 'setosa' 'virginica'\n",
            " 'virginica' 'virginica' 'virginica' 'virginica' 'setosa' 'setosa']\n",
            "\n",
            "              precision    recall  f1-score   support\n",
            "\n",
            "      setosa       1.00      1.00      1.00        10\n",
            "  versicolor       1.00      1.00      1.00         9\n",
            "   virginica       1.00      1.00      1.00        11\n",
            "\n",
            "    accuracy                           1.00        30\n",
            "   macro avg       1.00      1.00      1.00        30\n",
            "weighted avg       1.00      1.00      1.00        30\n",
            "\n",
            "1.0\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}